place_free


描述

You can use this function to check and see if the calling instance would collide with any instance flagged as solid in your game. Now, it should be noted that for this to work, the instance running the code must have a valid collision mask (either for the sprite itself, or through the mask_index) and it will only register collisions with those solid flagged instances that also have a valid mask.

The function itself basically works by taking the instance and testing for collisions with only solid flagged instances when placed at the position specified by the x/y arguments. The collision checking can be either precise or based on the bounding box of the instance, depending on what kind of collision mask has been selected.

Note that the given x/y coordinates will be floored to the nearest integer before the check is performed.


语法:

place_free(x, y);

参数 描述
x The x position to check.
y The y position to check.


返回:

Boolean(布尔值)


例如:

if place_free(mouse_x, mouse_y)
   {
   x = mouse_x;
   y = mouse_y;
   }

The above code will check for a collision with any solid flagged instance if the calling instance were to be placed at the same position as the mouse. If there is no collision detected, then the instance has its x/y coordinates set to those of the mouse.